package com.hunan.api.catv.action.sms;

import com.hunan.api.catv.action.BaseAction;
import com.hunan.api.catv.common.Api;
import com.hunan.api.catv.entity.Result;
import com.hunan.api.catv.service.biz.tencent_cloud.sms.SmsBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


@RestController
@RequestMapping(Api.sms)
@Validated
public class SmsAction extends BaseAction {

    @Autowired
    SmsBiz smsBiz;

    @PostMapping("/send")
    public Result send(HttpServletRequest request, @NotBlank(message = "phone is required") String phone, @NotNull(message = "smsType is required") Integer smsType) {
        return buildResult(smsBiz.send(phone, smsType));
    }
}
